package com.xnyzc.lhy.mis.mapper.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xnyzc.lhy.mis.entity.result.cms.driver.CmsOaDVehicleGpsRes;
import com.xnyzc.lhy.mis.entity.result.office.DUserInfoResult;
import com.xnyzc.lhy.mis.entity.user.OaDUserInfo;
import com.xnyzc.lhy.mis.entity.user.OaDUserOffice;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户信息表 Mapper 接口
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-18
 */
public interface OaDUserInfoMapper extends BaseMapper<OaDUserInfo> {


    /**
     * 获取指定司机简略信息
     *
     * @param managerId
     * @return
     */
   /* @Select(
        "<script>" +
            "SELECT  " +
            "duser.driver_id AS driverId," +
            "duser.driver_name AS driverName," +
            "duser.driver_phone AS driverPhone," +
            "area.name AS cityName," +
            "veh.veh_no AS vehNo," +
            "veh.veh_type AS vehType," +
            "userInfo.order_quantity_completed AS orderCompleted," +
            "userInfo.update_time AS updateTime," +
            "userInfo.vehicle_team AS vehicleTeam  " +

            "from oa_d_user_office as doffice   " +

            "LEFT JOIN oa_d_user as duser " +
            "ON doffice.driver_id = duser.driver_id " +
            "LEFT JOIN oa_d_user_info as userInfo " +
            "ON duser.driver_id = userInfo.driver_id " +
            "LEFT JOIN oa_d_driver_vehicle as userVeh " +
            "ON userVeh.driver_id = duser.driver_id " +
            "LEFT JOIN oa_sys_vehicle as veh  " +
            "ON userVeh.vehicle_id = veh.vehicle_id  " +
            "LEFT JOIN oa_sys_area as area  " +
            "ON userInfo.driver_city_id = area.ad_code  " +
            "WHERE duser.deleted = 0  " +
            "AND userInfo.deleted =0  " +
            "AND userVeh.deleted =0  " +
            "AND veh.deleted =0  " +
            "AND doffice.office_id =#{managerId}  " +
            "<if test=' driverName != null and driverName.length() != 0'  >" +
            "AND duser.driver_name LIKE CONCAT('%',#{driverName},'%')   " +
            "</if>  " +
            "<if test=' driverPhone != null and driverPhone.length() != 0'  >" +
            "AND duser.driver_phone LIKE CONCAT('%',#{driverPhone},'%')   " +
            "</if>  " +
            "<if test=' vehNo != null and vehNo.length() != 0'  >" +
            "AND veh.veh_no LIKE CONCAT('%',#{vehNo},'%')   " +
            "</if>  " +
            "<if test=' vehicleTeam != null and vehicleTeam.length() != 0'  >" +
            "AND userInfo.vehicle_team LIKE CONCAT('%',#{vehicleTeam},'%')   " +
            "</if>  " +
            "<if test=' vehicleType != null '  >" +
            "AND veh.veh_type =#{vehicleType}   " +
            "</if>  " +
       "</script>"
            )*/
    List<DUserInfoResult> getDriverInfo(@Param("managerId") String managerId, @Param("vehicleTeam")String vehicleTeam,
                                        @Param("driverName") String driverName, @Param("driverPhone") String driverPhone,
                                        @Param("vehNo") String vehNo, @Param("vehicleType") Integer vehicleType);

    List<OaDUserInfo> selectDriverIdsByOfficeOrCity(@Param("officeId")Long officeId,@Param("driverCityId")String driverCityId);
}
